package com.example.androidemoji;

import info.guardianproject.emoji.EmojiGroup;
import info.guardianproject.emoji.EmojiManager;
import info.guardianproject.emoji.EmojiPagerAdapter;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.widget.EditText;

import com.google.gson.JsonSyntaxException;

public class EmojiSampleActivity extends Activity {

	private final static String TAG = "EmojiSample";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_emoji_sample);

		EditText tv = (EditText) findViewById(R.id.textview_emoji_display);

		EmojiManager eManager = EmojiManager.getInstance(this);

		try {
			eManager.addJsonDefinitions("phantomsmiles.json", "phantom", "png");
			eManager.addJsonDefinitions("stickers.json", "stickers", "png");
			//eManager.addJsonDefinitions("poe.json", "emoji", "svg");
			
			
			Collection<EmojiGroup> emojiGroups = eManager.getEmojiGroups();

			EmojiPagerAdapter emojiPagerAdapter = new EmojiPagerAdapter(this,
					tv, new ArrayList<EmojiGroup>(emojiGroups));
			ViewPager vPager = (ViewPager) this.findViewById(R.id.emojiPager);
			vPager.setAdapter(emojiPagerAdapter);

		} catch (JsonSyntaxException jse) {
			Log.e(TAG, "could not parse json", jse);
		} catch (IOException fe) {
			Log.e(TAG, "could not load emoji definition", fe);
		} catch (Exception fe) {
			Log.e(TAG, "could not load emoji definition", fe);
		}

	}

}
